home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / tvdmx.exe / WORKSHOP.PAS < prev   
Pascal/Delphi Source File  |  1992-07-16  |  6KB  |  200 lines

  1.  
  2. {■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
  3. {                            }
  4. {    WORKSHOP  --generic tvDMX demo program        }
  5. {    tvDMX      --data editing project (ver 1.5)    }
  6. {                            }
  7. {    Copyright (c) 1992  Randolph Beck        }
  8. {                P.O. Box  56-0487        }
  9. {                Orlando, FL 32856        }
  10. {                CIS:  72361,753        }
  11. {                            }
  12. {■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
  13.  
  14. Program WORKSHOP;
  15.  
  16. {  This program was added to allow you to experiment with your own file
  17.    structures.  Just edit the strings xTemplate and xLabels and you will see
  18.    how easy it is to create new record structures --and what could go wrong
  19.    if you mix types or leave out field delimiters.
  20.  
  21.    A record structure does not need to be defined to the compiler because
  22.    this application uses a generic database of 8000 bytes (using the record
  23.    structure specified by the string xTemplate).
  24.  
  25.    All you need to do is edit xTemplate and xLabels: tvDMX will do the rest.
  26.  }
  27.  
  28. {$M 16384,16384,655360}
  29. {$V-,X+,D-,B-,R- }
  30.  
  31. uses
  32.     Objects, Drivers, Views, Menus, App,
  33.     RSet, DmxGizma, tvDMX, tvDMXREP, tvGizma;
  34.  
  35. const
  36.     xLabels    =  ' String Field            +Real         Real      Word   Seg : Ofs ';
  37.  
  38.     xTemplate  =  ' ssssssssssssssssssss║RRRRRRR.RRR |($rr,rrr.rr)|WWWWW ║ HHHH:HHHH ';
  39.  
  40.  
  41.     MyTemplate :  string [length (xTemplate)] =  xTemplate;
  42.     MyLabels   :  string [length (xLabels)]   =  xLabels;
  43.  
  44.     cmOpenWin       =  101;
  45.     cmReport        =  102;
  46.  
  47.  
  48. type
  49.     PDmxInterior    = ^TDmxInterior;
  50.     TDmxInterior    =  OBJECT (TDmxEditor)
  51.  
  52.      { see documentation on tvDMX's virtual methods if you wish to
  53.        modify your tvDMX view's behavior  }
  54.  
  55.     end;
  56.  
  57.  
  58.     TAppN        =  OBJECT (TAppA)
  59.     end;
  60.  
  61.  
  62.     TMyApp          =  OBJECT (TAppN)
  63.       constructor Init;
  64.       procedure HandleEvent (var Event : TEvent);  VIRTUAL;
  65.       procedure Idle;  VIRTUAL;
  66.       procedure InitMenuBar;  VIRTUAL;
  67.       procedure OpenWindow;
  68.     end;
  69.  
  70.  
  71. var
  72.     WorkWindow  :  array [1..5000] of byte;  { generic database }
  73.  
  74.  
  75.   { ══ TDmxInterior ══════════════════════════════════════════════════════ }
  76.  
  77.  
  78.      { see documentation on tvDMX's virtual methods if you wish to
  79.        modify your tvDMX view's behavior  }
  80.  
  81.  
  82.   { ══ TMyApp ════════════════════════════════════════════════════════════ }
  83.  
  84.  
  85. constructor TMyApp.Init;
  86. begin
  87.   TAppN.Init;
  88.   OpenWindow;
  89. end;
  90.  
  91.  
  92. procedure TMyApp.HandleEvent (var Event : TEvent);
  93.  
  94.     procedure DoReport;
  95.     begin
  96.       DmxReportBox ('Working', 'Processing report...'^M^M^C'WORKSHOP.OUT',
  97.     New (PDmxReportFile, Init (Message (DeskTop, evCommand, cmDMX_RollCall, @Self),
  98.          '|', TRUE, 50,78, 'WORKSHOP.OUT')));
  99.     end;
  100.  
  101. begin
  102.   TAppN.HandleEvent (Event);
  103.   If Event.What = evCommand then
  104.     begin
  105.     Case Event.Command of
  106.       cmOpenWin:  OpenWindow;
  107.       cmReport:   DoReport;
  108.      else         Exit;
  109.       end;
  110.     ClearEvent (Event);
  111.     end;
  112. end;
  113.  
  114.  
  115. procedure TMyApp.Idle;
  116. begin
  117.   TAppN.Idle;
  118.   If (Message (DeskTop, evCommand, cmDMX_RollCall, @Self) <> nil) then
  119.     EnableCommands ([cmReport])
  120.    else
  121.     DisableCommands ([cmReport]);
  122. end;
  123.  
  124.  
  125. procedure TMyApp.InitMenuBar;
  126. var  R: TRect;
  127. begin
  128.   GetExtent (R);
  129.   R.B.Y := R.A.Y + 1;
  130.   MenuBar := New (PMenuBar, Init (R, NewMenu (
  131.     NewSubMenu ('tv~DMX~', hcNoContext, NewMenu (
  132.       NewItem ('~O~pen',    'F4',   kbF4,   cmOpenWin, hcNoContext,
  133.       NewItem ('~R~eport',  'F9',   kbF9,   cmReport,  hcNoContext,
  134.       NewLine (
  135.       NewSoundItem (hcNoContext,
  136.       NewVideoItem (hcNoContext,
  137.       NewLine (
  138.       NewItem ('e~X~it',  'Alt-X',  kbAltX, cmQuit,    hcNoContext,
  139.       nil)))))))),
  140.     NewSubMenu ('~W~indow', hcNoContext, NewMenu (
  141.       NewItem ('~S~ize/Move', 'Ctrl-F5', kbCtrlF5, cmResize, hcNoContext,
  142.       NewItem ('~Z~oom',      'F5',  kbF5,    cmZoom,    hcNoContext,
  143.       NewItem ('~T~ile',      '',    kbNoKey, cmTile,    hcNoContext,
  144.       NewItem ('C~a~scade',   '',    kbNoKey, cmCascade, hcNoContext,
  145.       NewItem ('~N~ext',      'F6',  kbF6,    cmNext,    hcNoContext,
  146.       NewItem ('~P~revious', 'Shift-F6', kbShiftF6, cmPrev, hcNoContext,
  147.       NewItem ('~C~lose', 'Alt-F3',  kbAltF3, cmClose,   hcNoContext,
  148.       NewLine (
  149.       NewItem ('~U~ser screen', 'Alt-F5',  kbAltF5, cmUserScreen, hcNoContext,
  150.       nil)))))))))),
  151.     nil)))
  152.   ));
  153. end;
  154.  
  155.  
  156. procedure TMyApp.OpenWindow;
  157. var  R  : TRect;
  158.      W  : PWindow;
  159. begin
  160.   AssignWinRect (R, length (MyLabels) + 2, 0);  { assign window dimensions }
  161.       { width of string MyLabels plus two for the border; }
  162.       { zero rows indicates extend to bottom of screen }
  163.  
  164.   New (W, Init (R, 'Work Window', NextWindowNumber));
  165.   With W^ do
  166.     begin
  167.     Options := Options or ofTileable; { must be tileable for AssignWinRect }
  168.     GetExtent (R);          { create new rectangle for editor object }
  169.     R.Grow (-1,-1);                  { shrink -1 to avoid borders }
  170.     Inc (R.A.Y, 2);             { make room for TDmxLabels object }
  171.     Insert (New (PDmxInterior,
  172.       Init (MyTemplate,                 { template string }
  173.         WorkWindow,                    { working data }
  174.         sizeof (WorkWindow),            { size of working data }
  175.         R,                    { view's rectangle }
  176.         New (PDmxLabels, InitInsert (W, @MyLabels)),{ label string }
  177.         New (PDmxRecInd, InitInsert (W, 10)),    { indicator width }
  178.         W^.StandardScrollBar (sbHandleKeyboard or sbHorizontal),
  179.         W^.StandardScrollBar (sbHandleKeyboard or sbVertical)
  180.         )
  181.         ));
  182.     end;
  183.   DeskTop^.Insert (ValidView (W));
  184. end;
  185.  
  186.  
  187.   { ══════════════════════════════════════════════════════════════════════ }
  188.  
  189.  
  190. var  MyApp: TMyApp;
  191.  
  192.  
  193. Begin
  194.   FillChar (WorkWindow, sizeof (WorkWindow), 0);
  195.  
  196.   MyApp.Init;
  197.   MyApp.Run;
  198.   MyApp.Done;
  199. End.
  200.